package cn.com.callback;
import groovy.json.*;
import groovy.swing.impl.DefaultAction;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.RequestDispatcher;
import cn.com.elite.EliteBean;
import java.security.MessageDigest;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import com.wisdge.dataservice.Result;
import java.util.Map;
import java.util.Date;
import java.util.HashMap;
import org.json.JSONObject;
import org.json.JSONArray;
import org.json.JSONException;
import cn.com.elite.Util;

/**
 *
 * @Title: spe_grab_ucis_sfchargeinfo
 * @Description:布吉短信账单（数据捞取）--内部接口
 * @author: cheih
 * @date 2021-04-15 14:28:00
 *
 */

public class spe_grab_ucis_sfchargeinfo implements ServiceBackInvoke{
	private static final Log log = LogFactory.getLog(spe_grab_ucis_sfchargeinfo.class);
	public String doCallBack(EliteBean eliteBean,HttpServletRequest request,HttpServletResponse response) {

		response.setCharacterEncoding("UTF-8");

		String getMethod = request.getMethod();
		log.debug("getMethod:" + getMethod);

		String inURL = "";
		String inData = "";
		String outData = "";
		long startTime,endTime;
		startTime = System.currentTimeMillis();
		//crm数据源
		String dataSourceID= "dataSource";
		//ucis数据源
		String dataSourceIDoa= "dataSource-oa";

		BufferedReader iny = null;
		if (getMethod.equals("GET")) {
			inURL = request.getParameter("url");
			inData = request.getParameter("data");
			log.debug("原始Get请求参数:" + inData);
		} else {
			inURL = request.getParameter("url");
			InputStreamReader reader = new InputStreamReader(request.getInputStream(), "UTF-8");
			iny = new BufferedReader(reader);
			String line;
			while ((line = iny.readLine()) != null) {
				inData += line;
			}
			log.debug("原始Post请求参数:URL=" + inURL + " Data=" + inData);
		}

		try {
			log.debug("-----------布吉短信账单（数据捞取）开始执行--------------" );
			//-----查询UCIS水短信账单计划------
			def getPlancountSelectSQL = eliteBean.chaxun_sql("SELECT count(*) as plancount FROM ucis.MessageInfo WHERE MESSAGETYPECODE = 'A00015' AND MESSAGESTATUS = '1' AND SENDYEARMONTH = to_char(sysdate,'yyyymm') and to_char(CREATETIME,'yyyy-mm-dd')>=to_char(sysdate,'yyyy-mm-dd')", dataSourceIDoa);
			//def getPlancountSelectSQL = eliteBean.chaxun_sql("SELECT count(*) as plancount FROM ucis.MessageInfo WHERE MESSAGETYPECODE = 'A00015' AND MESSAGESTATUS = '1'", dataSourceIDoa);
			def plancount=0;
			plancount = getPlancountSelectSQL.get(0).get("plancount");
			log.debug("查询ucis当前短信账单结果数量:" + plancount);			
			
			if(plancount>0) {				
				//获取随机的36位id
				String plan_ID = UUID.randomUUID().toString();
				log.debug("短信账单计划36位唯一id:" + plan_ID);

				Date d = new Date();
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				String te_Starttime = sdf.format(d);
				log.debug("短信账单计划开始执行时间:" + te_Starttime);

				//-----查询UCIS短信账单计划详情------
				def getPlanSelectSQL = eliteBean.chaxun_sql("select a.MESSAGEINFOID as MESSAGEINFOID,a.SENDYEARMONTH as SENDYEARMONTH,a.BATCH as BATCH,a.MESSAGETYPENAME as MESSAGETYPENAME,a.DEPTCODE as DEPTCODE,a.MESSAGECOUNT as MESSAGECOUNT,a.MESSAGESTATUS as MESSAGESTATUS,a.createtime as createtime,a.MESSAGETYPECODE as MESSAGETYPECODE from ( select t.MESSAGEINFOID,t.SENDYEARMONTH,t.BATCH,t.MESSAGETYPENAME,t.DEPTCODE,t.MESSAGECOUNT,t.MESSAGESTATUS,t.createtime,t.MESSAGETYPECODE, row_number() over(order by t.createtime desc) rowss from ucis.MessageInfo t WHERE t.MESSAGETYPECODE = 'A00015' AND t.MESSAGESTATUS = '1' AND t.SENDYEARMONTH = to_char(sysdate,'yyyymm') ) a where a.rowss=1", dataSourceIDoa);
				//def getPlanSelectSQL = eliteBean.chaxun_sql("select a.MESSAGEINFOID as MESSAGEINFOID,a.SENDYEARMONTH as SENDYEARMONTH,a.BATCH as BATCH,a.MESSAGETYPENAME as MESSAGETYPENAME,a.DEPTCODE as DEPTCODE,a.MESSAGECOUNT as MESSAGECOUNT,a.MESSAGESTATUS as MESSAGESTATUS,a.createtime as createtime,a.MESSAGETYPECODE as MESSAGETYPECODE from ( select t.MESSAGEINFOID,t.SENDYEARMONTH,t.BATCH,t.MESSAGETYPENAME,t.DEPTCODE,t.MESSAGECOUNT,t.MESSAGESTATUS,t.createtime,t.MESSAGETYPECODE, row_number() over(order by t.createtime desc) rowss from ucis.MessageInfo t WHERE t.MESSAGETYPECODE = 'A00015' AND t.MESSAGESTATUS = '1' ) a where a.rowss=1", dataSourceIDoa);

				def MESSAGEINFOID,SENDYEARMONTH,BATCH,MESSAGETYPENAME,DEPTCODE,MESSAGECOUNT,MESSAGESTATUS,createtime,MESSAGETYPECODE;
				if(getPlanSelectSQL.size()>0) {
					log.debug("查询ucis短信账单 当前 SQL:" + getPlanSelectSQL);
					MESSAGEINFOID = getPlanSelectSQL.get(0).get("MESSAGEINFOID");
					SENDYEARMONTH = getPlanSelectSQL.get(0).get("SENDYEARMONTH");//年月
					BATCH = getPlanSelectSQL.get(0).get("BATCH");//批次
					MESSAGETYPENAME = getPlanSelectSQL.get(0).get("MESSAGETYPENAME");//类型（名称）
					DEPTCODE = getPlanSelectSQL.get(0).get("DEPTCODE");//部门编号
					MESSAGECOUNT = getPlanSelectSQL.get(0).get("MESSAGECOUNT");//短信总数
					MESSAGESTATUS = getPlanSelectSQL.get(0).get("MESSAGESTATUS");//短信状态
					createtime = getPlanSelectSQL.get(0).get("createtime");//时间
					
					MESSAGETYPECODE = getPlanSelectSQL.get(0).get("MESSAGETYPECODE");//类型(编号)
					//-----查询本地计划-----
					def getcrmSelectSQL = eliteBean.chaxun_sql("SELECT COUNT(*) as crmplancount FROM Ucis_Smssendplan WHERE TYPE_ID = '" + MESSAGETYPECODE + "' 	AND BATCH='" + BATCH + "' AND DEPTCODE='" + DEPTCODE + "' AND REPLACE(CONVERT(varchar(7),CTEATEDDATE,120) , '-', '')='" + SENDYEARMONTH + "' AND MESSAGEINFOID='" + MESSAGEINFOID + "'", dataSourceID);
					def crmplancount=0;
					crmplancount = getcrmSelectSQL.get(0).get("crmplancount");
					log.debug("查询CRM的短信账单批次计划的结果:" + crmplancount);

					//------------创建计划-------------
					//小于1则说明本地计划表没有相匹配的计划任务，这时则需创建计划任务
					if(crmplancount<1) {
						//创建短信账单批次
						def insertUcis_SmssendplanSQL="INSERT INTO Ucis_Smssendplan(rec_guid,TYPE_ID,BATCH,CTEATEDDATE,DEPTCODE,SMS_NAME,status,JHKSTIME,MESSAGEINFOID,SMS_JSSC,MESSAGECOUNT) SELECT '" + plan_ID + "','" + MESSAGETYPECODE + "' ,'" + BATCH + "' ,GETDATE(),'" + DEPTCODE + "',LEFT('" + SENDYEARMONTH + "',4)+'年'+SUBSTRING('" + SENDYEARMONTH + "',5,6)+'月'+'布吉'+'" + MESSAGETYPENAME + "' + '批次('+CAST('" + BATCH + "' as VARCHAR)+ ')',0,'" + createtime + "','" + MESSAGEINFOID + "',300,'" + MESSAGECOUNT + "'";
						log.debug("插入Ucis_Smssendplan表SQL:" + insertUcis_SmssendplanSQL);
						def insertUcis_SmssendplanFlag = eliteBean.update(insertUcis_SmssendplanSQL, dataSourceID);
						log.debug("插入Ucis_SmssendplanSQL执行结果:" + insertUcis_SmssendplanFlag);

						//查询ucis短信片段数量
						def getsfslbdcountSelectSQL = eliteBean.chaxun_sql("SELECT count(*) as sfslbdcount  FROM ucis.ucis_sf_charge_info where ghbtype is null and yf=to_char(sysdate,'mm') and nf=to_char(sysdate,'yyyy') and DEPTCODE='" + DEPTCODE + "' AND BATCH='" + BATCH + "'", dataSourceIDoa);
						//def getsfslbdcountSelectSQL = eliteBean.chaxun_sql("SELECT count(*) as sfslbdcount  FROM ucis.ucis_sf_charge_info where ghbtype is null  and DEPTCODE='" + DEPTCODE + "' AND BATCH='" + BATCH + "'", dataSourceIDoa);
						def sfslbdcount = getsfslbdcountSelectSQL.get(0).get("sfslbdcount");
						log.debug("查询ucis当前短信账单短信片段数量:" + sfslbdcount);

						//水量波动短信片段表数据大于0
						if(sfslbdcount>0) {
							//写入监控表
							def insertucis_sms_monitoringSQL= "insert into ucis_sms_monitoring(SMS_GUID,source_sum,type_id,grab_starttime,createdate) values('" + plan_ID + "','" + sfslbdcount + "','A00015',GETDATE(),GETDATE())";
							log.debug("插入ucis_sms_monitoring表SQL:" + insertucis_sms_monitoringSQL);
							def insertucis_sms_monitoringFlag = eliteBean.update(insertucis_sms_monitoringSQL, dataSourceID);
							log.debug("插入ucis_sms_monitoringSQL执行结果:" + insertucis_sms_monitoringFlag);

							//写入UCIS_CJ_result表				
							def insertUCIS_CJ_resultSQL="insert into UCIS_CJ_result(cj_guid,type,sourcedata,createdate) values('" + plan_ID + "','A00015','" + sfslbdcount + "',GETDATE())";
							log.debug("插入UCIS_CJ_result表SQL:" + insertUCIS_CJ_resultSQL);
							def insertUCIS_CJ_resultFlag = eliteBean.update(insertUCIS_CJ_resultSQL, dataSourceID);
							log.debug("插入UCIS_CJ_resultSQL执行结果:" + insertUCIS_CJ_resultFlag);

							//查询ucis短信片段详情
							//def getsfslbdSelectSQL = eliteBean.chaxun_sql("select itemid,nf,yf,sjhm,yhbh,ysdz,lcbrq,cbrq,ysl,bysf,bypsf,byljf,tqje,sfznj,psfznj,ljfznj,fslx,deptid,resultdata,SendTime,inputtime,batch,IsZNJ,Lscsj,Cscsj,deptcode,sfCostYearMonthStr,psfCostYearMonthStr,ljfCostYearMonthStr,RecordStr,reducedMoney,ISGSJT  FROM ucis.ucis_sf_charge_info where ghbtype is null and yf=to_char(sysdate,'mm') and nf=to_char(sysdate,'yyyy') and DEPTCODE='" + DEPTCODE + "' AND BATCH='" + BATCH + "' ", dataSourceIDoa);
							
							def getsfslbdSelectSQL="select itemid,nf,yf,sjhm,yhbh,ysdz,lcbrq,cbrq,ysl,bysf,bypsf,byljf,tqje,sfznj,psfznj,ljfznj,fslx,deptid,resultdata,SendTime,inputtime,batch,IsZNJ,Lscsj,Cscsj,deptcode,sfCostYearMonthStr,psfCostYearMonthStr,ljfCostYearMonthStr,RecordStr,reducedMoney,ISGSJT  FROM ucis.ucis_sf_charge_info where ghbtype is null and yf=to_char(sysdate,'mm') and nf=to_char(sysdate,'yyyy') and DEPTCODE='" + DEPTCODE + "' AND BATCH='" + BATCH + "' ";
							def maplist = eliteBean.chaxun_sqlRowSet(getsfslbdSelectSQL, dataSourceIDoa);
							
							//log.debug("getsfslbdSelectSQL结果结果:" + getsfslbdSelectSQL);
							log.debug("getsfslbdSelectSQL执行完成！");
							
							def pageSize = "100";
							int number = sfslbdcount/Integer.parseInt(pageSize);
							log.debug("number :" + number);
							int count=number+1;
							log.debug("count :" + count);
							int yscount = sfslbdcount-(number*Integer.parseInt(pageSize));
							log.debug("yscount :" + yscount);
		
							int datacount = 0;//结果更新的data
							//判断data长度,根据实际情况重置申明
							if (count == 1 && yscount > 0) {
								datacount = yscount;
							} else {
								datacount = 100;
							}
							//默认申明100条,用于list批次提交缓存
							String[] data = new String[datacount];
							//累计数 m 提交缓存累计数、 n提交缓存批次数
							int m =0, n = 0;
							def insertucis_sf_charge_infoSQL="";
							
							def itemid,nf,yf,sjhm,yhbh,ysdz,lcbrq,cbrq,ysl,bysf,bypsf,byljf,tqje,sfznj,psfznj,ljfznj,fslx,deptid,resultdata,SendTime,inputtime,batch,IsZNJ,Lscsj,Cscsj,deptcode,sfCostYearMonthStr,psfCostYearMonthStr,ljfCostYearMonthStr,RecordStr,reducedMoney,ISGSJT;
							//循环写入短信片段表
							//for (int i = 0; i <sfslbdcount; i++) {
							while (maplist.next()) {
								itemid = maplist.getString(1);
								nf = maplist.getString(2);
								yf = maplist.getString(3);
								sjhm = maplist.getString(4);
								yhbh = maplist.getString(5);
								ysdz = maplist.getString(6);
								lcbrq = maplist.getString(7);
								cbrq = maplist.getString(8);
								ysl = maplist.getString(9);
								bysf = maplist.getString(10);
								bypsf = maplist.getString(11);
								byljf = maplist.getString(12);
								tqje = maplist.getString(13);
								sfznj = maplist.getString(14);
								psfznj = maplist.getString(15);
								ljfznj = maplist.getString(16);
								fslx = maplist.getString(17);
								deptid = maplist.getString(18);
								resultdata = maplist.getString(19);
								SendTime = maplist.getString(20);
								inputtime = maplist.getString(21);
								batch = maplist.getString(22);
								IsZNJ = maplist.getString(23);
								Lscsj = maplist.getString(24);
								Cscsj = maplist.getString(25);
								deptcode = maplist.getString(26);
								sfCostYearMonthStr = maplist.getString(27);
								psfCostYearMonthStr = maplist.getString(28);
								ljfCostYearMonthStr = maplist.getString(29);
								RecordStr = maplist.getString(30);
								reducedMoney = maplist.getString(31);
								//ISGSJT = maplist.getString(32);
								ISGSJT =  0;

								//def insertucis_sf_charge_infoSQL="insert into ucis_sf_charge_info (itemid,nf,yf,sjhm,dhhm,yhbh,ysdz,lcbrq,cbrq,ysl,bysf,bypsf,byljf,tqje,sfznj,psfznj,ljfznj,fslx,deptid,resultdata,SendTime,inputtime,batch,IsZNJ,Lscsj,Cscsj,deptcode,sfCostYearMonthStr,psfCostYearMonthStr,ljfCostYearMonthStr,RecordStr,ISGSJT,sms_guid) select '" + itemid + "','" + nf + "','" + yf + "','" + sjhm + "','','" + yhbh + "','" + ysdz + "','" + lcbrq + "','" + cbrq + "','" + ysl + "','" + bysf + "','" + bypsf + "','" + byljf + "','" + tqje + "','" + sfznj + "','" + psfznj + "','" + ljfznj + "','" + fslx + "','" + deptid + "','" + resultdata + "','" + SendTime + "','" + inputtime + "','" + batch + "','" + IsZNJ + "','" + Lscsj + "','" + Cscsj + "','" + deptcode + "','" + sfCostYearMonthStr + "','" + psfCostYearMonthStr + "','" + ljfCostYearMonthStr + "','" + RecordStr + "','" + reducedMoney + "','" + ISGSJT + "','" + plan_ID + "'";
								//log.debug("insertucis_sf_charge_infoSQL:" + insertucis_sf_charge_infoSQL);
								//insertucis_sf_charge_infoSQL=insertucis_sf_charge_infoSQL.replace("'null'","null"); 
								//log.debug("insertucis_sf_charge_infoSQL null值 字符串 替换处理后:" + insertucis_sf_charge_infoSQL);
								//eliteBean.update(insertucis_sf_charge_infoSQL, dataSourceID);
								
								insertucis_sf_charge_infoSQL="insert into ucis_sf_charge_info (itemid,nf,yf,sjhm,dhhm,yhbh,ysdz,lcbrq,cbrq,ysl,bysf,bypsf,byljf,tqje,sfznj,psfznj,ljfznj,fslx,deptid,resultdata,SendTime,inputtime,batch,IsZNJ,Lscsj,Cscsj,deptcode,sfCostYearMonthStr,psfCostYearMonthStr,ljfCostYearMonthStr,RecordStr,reducedMoney,ISGSJT,sms_guid) select '" + itemid + "','" + nf + "','" + yf + "','" + sjhm + "','','" + yhbh + "','" + ysdz + "','" + lcbrq + "','" + cbrq + "','" + ysl + "','" + bysf + "','" + bypsf + "','" + byljf + "','" + tqje + "','" + sfznj + "','" + psfznj + "','" + ljfznj + "','" + fslx + "','" + deptid + "','" + resultdata + "','" + SendTime + "','" + inputtime + "','" + batch + "','" + IsZNJ + "','" + Lscsj + "','" + Cscsj + "','" + deptcode + "','" + sfCostYearMonthStr + "','" + psfCostYearMonthStr + "','" + ljfCostYearMonthStr + "','" + RecordStr + "','" + reducedMoney + "','" + ISGSJT + "','" + plan_ID + "'";
								insertucis_sf_charge_infoSQL=insertucis_sf_charge_infoSQL.replace("'null'","null");
								data[m] = insertucis_sf_charge_infoSQL;
								
								//累计
								m++;
								if (m == 100 || (count == n + 1 && m == yscount)) {
									//log.debug("批量更新短信捞取处理SQL:" + data.toString());
									int[] dataresult = eliteBean.updateBatch(data, "dataSource");
									//log.debug("批量更新短信捞取处理SQL结果:" + dataresult.toString());
		
									//判断data长度,根据实际情况重置申明
									if (count == n+2 && yscount > 0) {
										datacount = yscount;
									} else {
										datacount = 100;
									}
									data = new String[datacount];
									//重新申明
									m = 0;
									//累计提交次数
									n++;
								}
							
							}

							//写完更新ucis批次表的标识GHBtype 状态
							def updateucis_sf_charge_infoSQL = "Update ucis.ucis_sf_charge_info  set GHBtype = 1 where ghbtype is null and Yf = to_char(sysdate,'mm')  And Nf =to_char(sysdate,'yyyy') 	And Deptcode = '" + DEPTCODE + "' AND BATCH='" + BATCH + "'";
							//def updateucis_sf_charge_infoSQL = "Update ucis.ucis_sf_charge_info  set GHBtype = 1 where ghbtype is null And Deptcode = '" + DEPTCODE + "' AND BATCH='" + BATCH + "'";
							log.debug("更新ucis.ucis_sf_charge_info表SQL:" + updateucis_sf_charge_infoSQL);
							def updateucis_sf_charge_infoFlag = eliteBean.update(updateucis_sf_charge_infoSQL, dataSourceIDoa);
							log.debug("更新ucis.ucis_sf_charge_infoSQL执行结果:" + updateucis_sf_charge_infoFlag);

							//计数
							def getphonecountSelectSQL = eliteBean.chaxun_sql("select COUNT(*) as phonecount from ucis_sf_charge_info where sms_guid='" + plan_ID + "' and LEN(sjhm)=11", dataSourceID);
							def phonecount = getphonecountSelectSQL.get(0).get("phonecount");
							log.debug("查询ucis_sf_charge_info表，有效手机号码数量:" + phonecount);

							//更新UCIS_CJ_result表
							def updateUCIS_CJ_resultSQL="update UCIS_CJ_result set phone_count='" + phonecount + "' where cj_guid='" + plan_ID + "'";
							log.debug("更新UCIS_CJ_result表SQL:" + updateUCIS_CJ_resultSQL);
							def updateUCIS_CJ_resultFlag = eliteBean.update(updateUCIS_CJ_resultSQL, dataSourceID);
							log.debug("更新UCIS_CJ_resultSQL执行结果:" + updateUCIS_CJ_resultFlag);

							def gettotalcountSelectSQL = eliteBean.chaxun_sql("select count(*) as totalcount from ucis_sf_charge_info where  sms_guid='" + plan_ID + "'", dataSourceID);
							def totalcount = gettotalcountSelectSQL.get(0).get("totalcount");
							log.debug("查询ucis_sf_charge_info表，所有手机号码数量:" + totalcount);

							//更新ucis_sms_monitoring表
							def updateucis_sms_monitoringSQL="update ucis_sms_monitoring set grab_sum='" + totalcount + "',grab_endtime=GETDATE(),grab_status=1 where SMS_GUID='" + plan_ID + "'";
							log.debug("更新ucis_sms_monitoring表SQL:" + updateucis_sms_monitoringSQL);
							def updateucis_sms_monitoringFlag = eliteBean.update(updateucis_sms_monitoringSQL, dataSourceID);
							log.debug("更新ucis_sms_monitoringSQL执行结果:" + updateucis_sms_monitoringFlag);

							//写入UCIS_CJ_result表
							def insertucis_sms_grabSQL="insert into ucis_sms_grab values('" + plan_ID + "','A00015',NULL,NULL)";
							log.debug("插入ucis_sms_grab表SQL:" + insertucis_sms_grabSQL);
							def insertucis_sms_grabFlag = eliteBean.update(insertucis_sms_grabSQL, dataSourceID);
							log.debug("插入ucis_sms_grabSQL执行结果:" + insertucis_sms_grabFlag);

						}else {
							log.debug("布吉短信账单短信片段数据捞取为空！");
						}

						//写完更新ucis.MessageInfo批次表的标识MESSAGESTATUS 状态
						def updateMessageInfoSQL = "UPDATE ucis.MessageInfo SET MESSAGESTATUS = '2',modifytime = SYSDATE WHERE SENDYEARMONTH='" + SENDYEARMONTH + "' AND	BATCH='" + BATCH + "' AND	MESSAGETYPENAME='" + MESSAGETYPENAME + "' AND DEPTCODE='" + DEPTCODE + "' AND MESSAGECOUNT='" + MESSAGECOUNT + "' AND	MESSAGESTATUS='" + MESSAGESTATUS + "' AND	MESSAGETYPECODE='" + MESSAGETYPECODE + "' AND MESSAGEINFOID='" + MESSAGEINFOID + "'";
						log.debug("更新ucis.MessageInfo表SQL:" + updateMessageInfoSQL);
						def updateMessageInfoFlag = eliteBean.update(updateMessageInfoSQL, dataSourceIDoa);
						log.debug("更新ucis.MessageInfo执行结果:" + updateMessageInfoFlag);

						//写入日志轨迹表
						def insermessage_operation_hisSQL="INSERT INTO message_operation_his VALUES ('" + plan_ID + "',LEFT('" + SENDYEARMONTH + "',4)+'年'+SUBSTRING('" + SENDYEARMONTH + "',5,6)+'月'+'布吉'+'" + MESSAGETYPENAME + "' + '批次('+CAST('" + BATCH + "' as VARCHAR)+ ')','job', GETDATE(), 'UCIS存在计划，进行计划抓取',NEWID())";
						log.debug("插入message_operation_his表SQL:" + insermessage_operation_hisSQL);
						def insertmessage_operation_hisFlag = eliteBean.update(insermessage_operation_hisSQL, dataSourceID);
						log.debug("插入message_operation_hisSQL执行结果:" + insertmessage_operation_hisFlag);

						def insertLog_Proc_DealtimeSQL="Insert Into Log_Proc_Dealtime(Log_Guid, Proc_Name, Run_No, Starttime, Endtime, Dealinfo, Dealtime, Remark) Values(Newid(), 'spe_grab_ucis_sfchargeinfo','" + plan_ID + "', '" + te_Starttime + "', Getdate(), '水量波动计划抓取及短信内容抓取', DateDiff(MS, '" + te_Starttime + "', GetDate()), 'spe_grab_ucis_sfchargeinfo任务调用:水务催缴流程水量波动计划抓取及短信内容抓取')";
						log.debug("插入message_operation_his表SQL:" + insertLog_Proc_DealtimeSQL);
						def insertLog_Proc_DealtimeFlag = eliteBean.update(insertLog_Proc_DealtimeSQL, dataSourceID);
						log.debug("插入message_operation_hisSQL执行结果:" + insertLog_Proc_DealtimeFlag);

						endTime = System.currentTimeMillis();
						outData = "{\"resultcode\":\"1\",\"resultmessage\":\"布吉短信账单内部接口处理完成、调用问题处理时长(毫秒):" + (endTime - startTime) + "\",\"data\":[]}";
					}

				}else {
					log.debug("布吉短信账单批次数据捞取为空！" );
					endTime = System.currentTimeMillis();
					outData = "{\"resultcode\":\"1\",\"resultmessage\":\"布吉短信账单内部接口处理完成,批次详情数据为空、调用问题处理时长(毫秒):" + (endTime - startTime) + "\",\"data\":[]}";
				}
			}else{
				endTime = System.currentTimeMillis();
				outData = "{\"resultcode\":\"1\",\"resultmessage\":\"布吉短信账单内部接口处理完成,批次数据为空、调用问题处理时长(毫秒):" + (endTime - startTime) + "\",\"data\":[]}";
			}
		} catch(Exception e) {
			//log.error("布吉短信账单内部接口处理异常" + e.getMessage());
			//失败返回
			endTime = System.currentTimeMillis();
			outData = "{\"resultcode\":\"0\",\"resultmessage\":\"布吉短信账单内部接口处理失败(" + e.getMessage() + "),调用问题处理时长(毫秒):" + (endTime - startTime) + "\",\"data\":[]}";
		}

		//log.info("布吉短信账单内部接口处理返回:" + outData);
		return outData;
	}
}